import hyRequest from '@/service'

// 查询用户列表
export function postUserListData(params?: object) {
  return hyRequest.post({
    url: '/users/list',
    data: params ?? {
      offset: 0,
      size: 10
    } // post请求要用data，params(get)请求需要?拼接
  })
}
// 删除用户
export function deleteUserById(id: number) {
  return hyRequest.delete({
    url: `/users/${id}`
  })
}
// 添加用户
export function newUserData(usersInfo: any) {
  return hyRequest.post({
    url: '/users',
    data: usersInfo
  })
}
// 编辑用户
export function editUserData(id: number, usersInfo: any) {
  return hyRequest.patch({
    url: `/users/${id}`,
    data: usersInfo
  })
}

// 重构后的查询list接口
// 查询
export function postPageListData(pageName: string, queryInfo: any) {
  return hyRequest.post({
    url: `/${pageName}/list`,
    data: queryInfo
  })
}
// 删除
export function deletePageById(pageName: string, id: number) {
  return hyRequest.delete({
    url: `/${pageName}/${id}`
  })
}
// 添加
export function newPageData(pageName: string, usersInfo: any) {
  return hyRequest.post({
    url: `/${pageName}`,
    data: usersInfo
  })
}
// 修改
export function editPageData(pageName: string, id: number, usersInfo: any) {
  return hyRequest.patch({
    url: `/${pageName}/${id}`,
    data: usersInfo
  })
}
